package com.qianfeng.smartmeeting.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.qianfeng.smartmeeting.entity.User;
import com.qianfeng.smartmeeting.mapper.UserMapper;
import com.qianfeng.smartmeeting.service.UserService;
//import org.springframework.security.core.authority.SimpleGrantedAuthority;
//import org.springframework.security.core.userdetails.UserDetails;
//import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Service;

import java.util.Collections;

@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements UserService {

    @Override
    public User getUserByUsername(String username) {
        return baseMapper.selectByUsername(username);
    }

    @Override
    public boolean checkUsernameExists(String username) {
        return baseMapper.countByUsername(username) > 0;
    }

//    @Override
//    public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
//        User user = getUserByUsername(username);
//        if (user == null) {
//            throw new UsernameNotFoundException("用户不存在");
//        }
//
//        return new org.springframework.security.core.userdetails.User(
//                user.getUsername(),
//                user.getPassword(),
//                Collections.singleton(new SimpleGrantedAuthority(user.getRole()))
//        );
//    }
}